package test;

public class EnumTest1 {

}

enum Operation {
	PLUS {
		@Override
		double apply(double a, double b) {
			return a + b;
		}
	},
	MINUS {
		@Override
		double apply(double a, double b) {
			return a - b;
		}
	},
	TIMES {
		@Override
		double apply(double a, double b) {
			return a * b;
		}
	};

	abstract double apply(double a, double b);
}

enum PayrollDay {
	MONDAY(PayType.WEEKDAY), TUESDAY(PayType.WEEKDAY), WEDNESDAY(PayType.WEEKDAY), THURSDAY(PayType.WEEKDAY), FRIDAY(
			PayType.WEEKDAY), SATURDAY(PayType.WEEKEND), SUNDAY(PayType.WEEKEND);

	private final PayType payType;

	PayrollDay(PayType p) {
		payType = p;
	}

	double pay(double hours, double payRate) {
		return payType.pay(hours, payRate);
	}

	private enum PayType {
		WEEKDAY {
			@Override
			double overtimePay(double hours, double payRate) {
				return hours <= HOURS_PER_SHIFT ? 0 : (hours - HOURS_PER_SHIFT) * payRate / 2;
			}
		},
		WEEKEND {
			@Override
			double overtimePay(double hours, double payRate) {
				return hours * payRate / 2;
			}
		};
		private static final int HOURS_PER_SHIFT = 8;

		abstract double overtimePay(double hours, double payRate);

		double pay(double hoursWorked, double payRate) {
			double basePay = hoursWorked * payRate;
			return basePay + overtimePay(hoursWorked, payRate);
		}
	}
}
